package manager.rawdata;

import manager.data.LazyPersistedQueue;

public class LazyPersistedRawData  extends Thread {

	private static QueueBackupObject qbo;
	private LazyPersistedQueue lpq;
	
	public LazyPersistedRawData(LazyPersistedQueue lpq) {
		this.lpq=lpq;
		qbo=QueueBackupObject.getInstance(lpq);
		qbo.loadBackup();
	}
	
	public void run() {
		handleSynchro();
	}

	private synchronized void handleSynchro(){
		while(true){
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			boolean trovato=true;
			while(trovato){
				qbo.insertBlock();
				//long backupSize = qbo.getSize();
				int memorySize = lpq.memorySizeTmp();
				if(memorySize>0)
					trovato=true;
				else
					trovato=false;
			}
		}
	}
}
